/*
 * Copyright (c) 2016. 恒昌互联网运营中心.
 */

package com.credithc.eagleeye.service.impl;
import com.credithc.eagleeye.config.EagleMonitorESConfig;
import com.credithc.eagleeye.queue.EagleTraceInfoQueueManager;
import com.credithc.eagleeye.service.RpcTraceInfoService;
import com.credithc.eagleeye.vo.RpcTraceInfoVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
 * 描 述: <br/>
 * 作 者: zhangjin<br/>
 * 创 建：2016年06月03日<br/>
 * 版 本：v1.0.0<br>
 * <p/>
 * 历 史: (版本) 作者 时间 注释 <br/>
 */
@Service("rpcTraceInfoService")
@Slf4j
public class RpcTraceInfoServiceImpl implements RpcTraceInfoService {
    @Autowired
    private EagleMonitorESConfig eagleMonitorESConfig;
    @Autowired
    private EagleTraceInfoQueueManager eagleTraceInfoQueueManager;


    @Override
    public boolean sendRpcTraceInfo(RpcTraceInfoVo rpcTraceInfoVo) {
        //如果未开启,直接返回成功,不放入队列里
        if(!eagleMonitorESConfig.isEnable()){
            return true;
        }
        return eagleTraceInfoQueueManager.offer(rpcTraceInfoVo);
    }
}
